<?php

class Notification {
	static $SUCCESS = 'success';
	static $ERROR = 'error';
	
	
	
	public static function add($type, $message) {
		if (!isset($_SESSION['notification'])) {
			$_SESSION['notification'] = array();
		}
		if (!isset($_SESSION['notification'][$type])) {
			$_SESSION['notification'][$type] = array();
		}
		$_SESSION['notification'][$type][] = $message;
	}
	
	
	public static function getAndClean($type) {
		$notifs = self::get($type);
		self::clean($type);
		return $notifs;
	}
	public static function get($type) {
		$notifs = array();
		if (self::count($type)) {
			$notifs = $_SESSION['notification'][$type];
		}
		return $notifs;
	}
	public static function clean($type) {
		if (self::count($type)) {
			$_SESSION['notification'][$type] = array();
		}
	}
	public static function count($type) {
		$total = 0;
		if (isset($_SESSION['notification']) && isset($_SESSION['notification'][$type])) {
			$total = count($_SESSION['notification'][$type]);
		}
		return $total;
	}
}